package com.bishe.app.modules.userSaleIncome.model;

import cn.hutool.core.lang.Pair;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created : 2024/4/6, 13:15
 *
 * @author : jeffrey.hu
 **/
public class UserIncomeKV {

    private static List<Pair<String, String>> getAllKvs() {
        String json = "[\n" +
                "    {\n" +
                "        \"key\": \"单人提成\",\n" +
                "        \"value\": \"singleTicheng\"\n" +
                "    },\n" +
                "    {\n" +
                "        \"key\": \"提成1\",\n" +
                "        \"value\": \"ticheng1\"\n" +
                "    },\n" +
                "    {\n" +
                "        \"key\": \"提成2\",\n" +
                "        \"value\": \"ticheng2\"\n" +
                "    },\n" +
                "    {\n" +
                "        \"key\": \"提成3\",\n" +
                "        \"value\": \"ticheng3\"\n" +
                "    },\n" +
                "    {\n" +
                "        \"key\": \"底薪\",\n" +
                "        \"value\": \"basicSalary\"\n" +
                "    },\n" +
                "    {\n" +
                "        \"key\": \"代班\",\n" +
                "        \"value\": \"daiban\"\n" +
                "    },\n" +
                "    {\n" +
                "        \"key\": \"休息\",\n" +
                "        \"value\": \"xiuxi\"\n" +
                "    },\n" +
                "    {\n" +
                "        \"key\": \"买版\",\n" +
                "        \"value\": \"maibanjiang\"\n" +
                "    },\n" +
                "    {\n" +
                "        \"key\": \"全勤奖\",\n" +
                "        \"value\": \"quanqinjiang\"\n" +
                "    },\n" +
                "    {\n" +
                "        \"key\": \"工龄\",\n" +
                "        \"value\": \"gongling\"\n" +
                "    },\n" +
                "    {\n" +
                "        \"key\": \"超奖\",\n" +
                "        \"value\": \"chaojiang\"\n" +
                "    },\n" +
                "    {\n" +
                "        \"key\": \"假日奖\",\n" +
                "        \"value\": \"jiarijiang\"\n" +
                "    },\n" +
                "    {\n" +
                "        \"key\": \"保险补贴\",\n" +
                "        \"value\": \"baoxianbutie\"\n" +
                "    },\n" +
                "    {\n" +
                "        \"key\": \"盘点\",\n" +
                "        \"value\": \"pandian\"\n" +
                "    },\n" +
                "    {\n" +
                "        \"key\": \"罚款\",\n" +
                "        \"value\": \"fakuan\"\n" +
                "    },\n" +
                "    {\n" +
                "        \"key\": \"实发工资\",\n" +
                "        \"value\": \"shifagongzi\"\n" +
                "    }\n" +
                "]\n";


        ArrayList<Pair<String, String>> kvs = new ArrayList<>();
        JSONArray objects = JSON.parseArray(json);
        for (int i = 0; i < objects.size(); i++) {
            JSONObject jsonObject = objects.getJSONObject(i);
            kvs.add(new Pair<>(jsonObject.getString("key"), jsonObject.getString("value")));
        }
        return kvs;
    }


    public static List<Pair<String, String>> shopKvs() {
        List<Pair<String, String>> kvs = getAllKvs();
        List<String> removeList = Arrays.asList("singleTicheng");
        kvs.removeIf(x -> removeList.contains(x.getValue().toString()));
        return kvs;
    }

    public static List<Pair<String, String>> officeKvs() {
        List<Pair<String, String>> pairs = getAllKvs();
        List<String> removeList = Arrays.asList("maibanjiang", "chaojiang", "quanqinjiang", "singleTicheng");
        pairs.removeIf(x -> removeList.contains(x.getValue().toString()));
        return pairs;
    }

    public static List<Pair<String, String>> shoeShopKvs() {
        List<Pair<String, String>> pairs = getAllKvs();
        List<String> removeList = Arrays.asList("chaojiang");
        pairs.removeIf(x -> removeList.contains(x.getValue().toString()));
        return pairs;
    }


    public static List<Pair<String, String>> getGroupKvs(int groupType) {
        switch (groupType) {
            case 1:
                // 服装店
                return shopKvs();
            case 2:
                return officeKvs();
            case 3:
                return officeKvs();
            case 4:
                return shoeShopKvs();
            default:
                throw new RuntimeException("请联系管理员，不支持的店铺类型");
        }
    }

}
